<template>
  <div>
    <div>
      <el-form :inline="true" @submit.native.prevent>
        <el-form-item>
          <el-input v-model="search" placeholder="请输入姓名" @keyup.enter.native="handleSearch" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div>
      <el-table v-loading="table.loading" :data="table.data" border>
        <el-table-column prop="name" label="姓名" />
        <el-table-column prop="mobile" label="手机" />
        <!--        <el-table-column label="性别">-->
        <!--          <template slot-scope="t">-->
        <!--            <span v-if="t.row.gender===1">男</span>-->
        <!--            <span v-if="t.row.gender===2">女</span>-->
        <!--            <span v-if="t.row.gender===3">未知</span>-->
        <!--          </template>-->
        <!--        </el-table-column>-->
        <el-table-column label="是否默认">
          <template slot-scope="t">
            <span v-if="t.row.is_admin===1">是</span>
            <span v-if="t.row.is_admin===0">否</span>
          </template>
        </el-table-column>
        <el-table-column prop="created_at" label="添加时间" />
      </el-table>
    </div>
    <WrapPagination>
      <el-pagination
        class="pagination"
        :current-page="table.page"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="table.size"
        layout="prev, pager, next"
        :total="table.total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </WrapPagination>
  </div>
</template>

<script>
import { TableMixin } from '../../components/mixin'
import { getList } from '../../api/employee'

export default {
  mixins: [TableMixin],
  data() {
    return {
      search: ''
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    getList() {
      this.wrapResourceList(getList, {
        search: this.search
      })
    },
    handleSearch() {
      this.getList()
    }
  }
}
</script>
